//
//  ViewController.m
//  UI02_UIImageHomeworkSecond
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createImageView];
    [self createAnimationImage1];
    [self createAnimationImage2];
    [self createAnimationImage3];
    [self createAnimationImageForFlower];
    [self createAnimationImageForGua];
    [self createAnimationImageForPlants];
    
    
    
    
    
}
-(void)createImageView {
    UIImage *image = [UIImage imageNamed:@"BackGround.png"];
    UIImageView *backgroundImageView =[[UIImageView alloc] initWithImage:image];
    backgroundImageView.frame = [UIScreen mainScreen].bounds;
    [self.view addSubview:backgroundImageView];
    [backgroundImageView release];
}

-(void)createAnimationImage1{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(200, 100, 200, 200);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for (int i = 1;i <= 25;i++){
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}

-(void)createAnimationImage2{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(200, 300, 200, 200);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for (int i = 1;i <= 25;i++){
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}

-(void)createAnimationImage3{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(200, 500, 200, 200);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for (int i = 1;i <= 25;i++){
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}

-(void)createAnimationImageForFlower{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower1.tiff"]];
    animationImageView.frame = CGRectMake(50, 100, 150, 150);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:18];
    
    for (int i = 1;i <= 18;i++){
        NSString *name = [NSString stringWithFormat:@"flower%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}

-(void)createAnimationImageForGua{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gua1.tiff"]];
    animationImageView.frame = CGRectMake(50, 300, 150, 150);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:16];
    
    for (int i = 1;i <= 16;i++){
        NSString *name = [NSString stringWithFormat:@"gua%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}

-(void)createAnimationImageForPlants{
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plants1.tiff"]];
    animationImageView.frame = CGRectMake(50, 500, 150, 150);
    
    [self.view addSubview:animationImageView];
    [animationImageView release];
    
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:9];
    
    for (int i = 1;i <= 9;i++){
        NSString *name = [NSString stringWithFormat:@"plants%d.tiff",i];
        UIImage *animationImage  = [UIImage imageNamed:name];
        
        [mutableArray addObject:animationImage];
    }
    
    
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 2;
    
    [animationImageView startAnimating];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
